<template>
  <div class="itemInfo wow fadeInDown">
    <div class="titleInfo"><p>安全运行天数</p></div>
    <div class="numBody">
      <numcard2 :number="num"></numcard2>
    </div>
  </div>
</template>

<script>
import numcard2 from "@/components/numcard2/index.vue";
import {gsap} from "gsap";
import {safeOperatingDays} from "@/api/api/LargeScreenData.js";

export default {
  components: {numcard2},
  data() {
    return {
      list: [],
      num: 0,
      showNumCard: false
    }
  },
  async mounted() {
    await this.getData()
    this.animateElements();
  },
  methods: {
    animateElements() {
      gsap.from(".itemInfoInner", {
        opacity: 0,
        y: -100,
        duration: 1,
        stagger: 0.3,
        onComplete: () => {
          this.showNumCard = true
        }
      });
    },
    async getData() {
      try {
        const res = await safeOperatingDays();
        this.num = res.data;
      } catch (err) {
        console.error(err);
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.itemInfo {
  position: relative;
  display: flex;
  margin-top: 20px;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: column;
  align-content: flex-start;
  background: url("./assets/numbg.png");
  width: 733px;
  height: 125px;
  background-size: 100% 100%;

  .titleInfo {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-top: -30px;

    p {
      transform: translateY(1em);
      animation: appear 0.5s forwards;
      animation-delay: var(--delay);
      font-size: 20px;
      font-family: AlibabaPuHuiTiB;
      font-weight: 400;
      background: linear-gradient(to bottom, #d6e1ff, #92bcff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }


  .itemInfoInner {
    width: 25%;
    position: relative;
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;

    .itemInfoInnerIcon {
      width: 56px;
      height: 56px;
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;

      .iconBg {
        position: absolute;
        top: 0;
        left: 0;
        background: url("./assets/itembg.png");
        background-size: 100% 100%;
        width: 100%;
        height: 100%;
        animation: rotateAnimation 6s infinite linear;
      }

      .iconBg2 {
        position: absolute;
        top: 0;
        width: 100%;
        left: 0;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: nowrap;
        flex-direction: row;
        align-content: flex-start;

        i {
          font-size: 24px;
          color: rgba(0, 187, 255, 1);
        }
      }
    }

    .itemInfoInnerR {
      margin-left: 10px;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      flex-wrap: nowrap;
      flex-direction: column;
      align-content: flex-start;

      p {
        font-size: 16px;
        font-family: MicrosoftYaHei;
        font-weight: 400;
        color: #DBE7FF;
      }
    }
  }
}

.numBody {
  margin-top: 38px;
  height: 100px;
}

</style>
